package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.User;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

import java.util.Map;

@Mapper
public interface UserMapper {


    @Select("select * from user where openid = #{openid}")
    User queryByOpenid(String openid);

    @Insert("insert into user(openid,create_time) values(#{openid},#{createTime})")
    //插入后将id返回
    @SelectKey(keyProperty = "id",before = false,resultType = Long.class,statement = "select last_insert_id()")
    void insert(User user);

    @Select("select * from user where id = #{id}")
    User queryById(Long id);

    Integer countByMap(Map map);
}
